package com.example.zlloggingservice.controller.inner;

import com.example.zlloggingservice.api.OperationLogApi;
import com.example.zlloggingservice.common.base.PageResponse;
import com.example.zlloggingservice.common.base.ResponseResult;
import com.example.zlloggingservice.dto.request.OperationLogReqDTO;
import com.example.zlloggingservice.dto.response.OperationLogResDTO;
import com.example.zlloggingservice.service.IOperationLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author zhenliu（孙凌岳）
 * @Description 内部接口 - 操作日志控制器（供 RPC 调用）
 * @Date 2025/6/20 16:39
 * @Version 1.0
 */
@RestController
@Api(tags = "内部接口 - 操作日志控制器", hidden = true)
@RequestMapping("/permission/inner/log")
public class InnerOperationLogController implements OperationLogApi {
    @Resource
    private IOperationLogService operationLogService;

    /**
     * 分页查询操作日志（RPC）
     * @param operationLogReqDTO
     * @param pageNum
     * @param pageSize
     * @return
     */
    @PostMapping("page/{pageNum}/{pageSize}")
    @ApiOperation(value = "分页查询操作日志（内部 RPC）", notes = "分页查询操作日志")
    public PageResponse<OperationLogResDTO> findOperationResDTOPage(
            @RequestBody OperationLogReqDTO operationLogReqDTO,
            @PathVariable("pageNum") int pageNum,
            @PathVariable("pageSize") int pageSize) {
        PageResponse<OperationLogResDTO> operationLogResDTOPageResponse = operationLogService.findOperationResDTOPage(operationLogReqDTO, pageNum, pageSize);
        return operationLogResDTOPageResponse;
    }

    /**
     * 根据操作日志 ID 删除
     * @param operId
     * @return
     */
    @DeleteMapping("/{operId}")
    @ApiOperation(value = "根据操作日志 ID 删除（内部 RPC）", notes = "删除指定操作日志")
    public ResponseResult remove(@PathVariable("operId") Long operId) {
        return ResponseResult.success(operationLogService.deleteLogById(operId));
    }
}
